<template>
  <div id='wrap'>
    <h1>路由进阶</h1>
    <p>meta元信息中的title标题{{ pageTitle }}</p>
    <RouterLink :to="{name:'scu39Son1',params:{id:'1000',title:'新闻标题',content:'新闻内容'}}">RouterView插槽子组件</RouterLink>
    <RouterView v-slot="{Component,route}">
      <transition :name="`${trans}`">
        <component :is="Component" :key="route.path" :view="obj"></component>
      </transition>
    </RouterView>
  </div>
</template>

<script lang='ts'>
export default {
  name: 'scu39',
}
</script>

<script lang='ts' setup>
import { ref } from 'vue'
import { useRoute } from "vue-router";
export interface classA{
  name:string
  sex:string
  age:number
}
const route=useRoute()
const pageTitle=route.meta.title || '默认标题'
const trans=route.meta.Transition || ''
const obj=ref<classA>({
  name:'小明',
  sex:'男',
  age:18
})
</script>

<style scoped lang='scss'>
/*
  进入和离开动画可以使用不同
  持续时间和速度曲线。
  使用：name="slide-fade"
*/
.slide-fade-enter-active {
  transition: all 0.3s ease-out;
}

.slide-fade-leave-active {
  transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}

.slide-fade-enter-from,
.slide-fade-leave-to {
  transform: translateX(20px);
  opacity: 0;
}

//使用 name="bounce"
.bounce-enter-active {
  animation: bounce-in 0.5s;
}
.bounce-leave-active {
  animation: bounce-in 0.5s reverse;
}
@keyframes bounce-in {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.25);
  }
  100% {
    transform: scale(1);
  }
}
</style>
